package br.com.segpswd;

import android.app.Activity;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.graphics.drawable.AnimationDrawable;
import android.os.Bundle;
import android.os.Handler;
import android.view.Menu;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.ImageView;

public class SplashScreen extends Activity implements Runnable {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);

		// ocultar a barra de titulo
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		
		setContentView(R.layout.activity_splash_screen);

		// activty somente na vertical
		this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);

		// Transparencia
		this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_BLUR_BEHIND,
				WindowManager.LayoutParams.FLAG_BLUR_BEHIND);

		final ImageView animationImageView = (ImageView) findViewById(R.id.imgSplashAnimation);
		animationImageView.setBackgroundResource(R.drawable.android_splash);

		final AnimationDrawable frameAnimation = (AnimationDrawable) animationImageView
				.getBackground();
		animationImageView.post(new Runnable() {
			@Override
			public void run() {
				frameAnimation.start();
			}
		});
		
		Handler h = new Handler();
		h.postDelayed(this, 1000);/*10000*/
	}
	
	@Override
	public void run() {
		ImageView animationImageView = (ImageView) findViewById(R.id.imgSplashAnimation);
		animationImageView.setVisibility(View.INVISIBLE);
		
		
		startActivity( new Intent(this, MenuPrincipalApp.class) );
		
		finish();
		
//		LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
//		View view = inflater.inflate(R.layout.activity_login, null);
//		this.setContentView(view);
//		
//		// button ACESSAR
//		Button btnAcessar = (Button) findViewById(R.id.btnAcessar);
//		
//		btnAcessar.invalidate();
	}
	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.splash_screen, menu);
		return true;
	}
	
	

}
